package Chapter11;

/**
 * @author 杨森
 * @date 2022年10月20日 17:22
 */
public class Homework04 {
    public static void main(String[] args) {
        Cellphone cellphone = new Cellphone();
        cellphone.testWork(new work() {
            @Override
            public double work(double n1, double n2) {
                return n1+n2;
            }
        },10,8);
    }
}

interface work{
    public double work(double n1,double n2);
}

class Cellphone {
//    匿名内部类完成计算
    public void testWork(work work1,double n1,double n2){
        double result=work1.work(n1,n2);
        System.out.println("结果="+result);
    }
}
